//
//  SEGOrderDetailSectionHeadView.m
//  Uhomebk
//
//  Created by mac on 2017/7/7.
//  Copyright © 2017年 com.segi. All rights reserved.
//

#import "SEGOrderDetailSectionHeadView.h"

@implementation SEGOrderDetailSectionHeadView

- (instancetype)init
{
    if (self == [super init]) {
        [self setupUI];
    }
    return self;
}


-(instancetype)initWithFrame:(CGRect)frame
{
    if (self == [super initWithFrame:frame]) {
        [self setupUI];
    }
    return self;
}

-(void)setIsOpen:(BOOL)isOpen
{
    _isOpen = isOpen;
    self.openBtn.selected = isOpen;
}

/**
 展开
 */
-(void)openAction:(UIButton *)sender 
{
    
    sender.selected = !sender.selected;
    
    if (self.delegate && [self.delegate respondsToSelector:@selector(isOpenShowView: type:)]) {
        [self.delegate isOpenShowView :sender.selected type:self.type];
    }
    
}

- (void)setupUI
{
    [self addSubview:self.titleLabel];
    [self addSubview:self.separateLine];
    
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker* make) {
        make.size.mas_equalTo(CGSizeMake(100, 44));
        make.top.equalTo(self);
        make.left.equalTo(self).offset(15);
    }];
    
    [_separateLine mas_makeConstraints:^(MASConstraintMaker* make) {
        make.size.mas_equalTo(CGSizeMake(LYScreenWidth(), 0.5));
        make.top.equalTo(_titleLabel.mas_bottom);
        make.left.equalTo(self);
    }];
    

    
}
- (UILabel*)titleLabel
{
    if (_titleLabel == nil) {
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.textColor = kColor_1;
        _titleLabel.font = kFont_15;
    }
    return _titleLabel;
}

- (UIView*)separateLine
{
    if (_separateLine == nil) {
        _separateLine = [[UIView alloc] init];
        _separateLine.backgroundColor = kColor_L2;
    }
    return _separateLine;
}

//-(UIButton*)openBtn
//{
//    if (_openBtn==nil) {
//        UIImage *openimage=[UIImage imageWithContentsOfFile:@"icon_open"];
//        UIImage *shrinkimage=[UIImage imageWithContentsOfFile:@"icon_shrink"];
//        _openBtn=[UIButton buttonWithType:UIButtonTypeCustom];
//        [_openBtn setTitle:@"展开" forState:UIControlStateNormal];
//        [_openBtn setTitle:@"收起" forState:UIControlStateSelected];
//        [_openBtn.titleLabel setFont:kFont_14];
//        [_openBtn.titleLabel sizeToFit];
//        [_openBtn setImage:openimage forState:UIControlStateNormal];
//        [_openBtn setImage:shrinkimage forState:UIControlStateSelected];
//        _openBtn.imageEdgeInsets = UIEdgeInsetsMake(0, 10+_openBtn.titleLabel.bounds.size.width, 0, -_openBtn.titleLabel.bounds.size.width);
//        [_openBtn addTarget:self action:@selector(openAction:) forControlEvents:UIControlEventTouchUpInside];
//        _openBtn.titleEdgeInsets = UIEdgeInsetsMake(0, -openimage.size.width, 0, openimage.size.width);
//    }
//    return _openBtn;
//}




@end
